package com.orangelife.service.propFeeCommInfo.impl;

import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import com.orangelife.exception.AppBizException;
import com.orangelife.service.propFeeComm.IPropFeeCommService;
import com.orangelife.service.propFeeComm.model.PropFeeCommDto;

public class HandleCommThread extends Thread implements Runnable {

	private String threadName;
	private List<Map<String, Object>> data;
	private int start;
	private int end;

	private IPropFeeCommService propFeeCommService;

	public HandleCommThread(String threadName, List<Map<String, Object>> data,
			IPropFeeCommService propFeeCommService) {
		this.threadName = threadName;
		this.data = data;
		this.propFeeCommService = propFeeCommService;
	}

	public void run() {
		try {
			System.out.println(threadName + "\t\t\t\t\t 请求 数据" + "\t\t\t\t"
					+ JSONObject.fromObject(data.get(0)).toString());
			List<PropFeeCommDto> propFeeCommDtos = propFeeCommService
					.findPropFeeCommByRelevantID(data.get(0).get("commID")
							.toString(), data.get(0).get("comm").toString());

			if (propFeeCommDtos == null || propFeeCommDtos.size() <= 0) {
				PropFeeCommDto pPropFeeCommDto = new PropFeeCommDto();
				pPropFeeCommDto.setComm(data.get(0).get("comm").toString());
				pPropFeeCommDto.setCommID(data.get(0).get("commID").toString());
				pPropFeeCommDto.setRemark(data.get(0).get("comm").toString());
				propFeeCommService.addPropFeeComm(pPropFeeCommDto);

			}
		} catch (AppBizException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
